package com.story.util;

import org.springframework.http.ResponseEntity;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Pyx
 * @PACKAGE_NAME : com.story.util
 * @FileName: ReturnObject
 * @date 2020/5/19 11:18
 */
public class ReturnObject {
    public static ResponseEntity ok(){
        Map<String, Object> map = new HashMap<>();
        map.put("message", "success");
        map.put("status", "200");
        return ResponseEntity.ok(map);
    }
    public static ResponseEntity ok(String msg){
        Map<String, Object> map = new HashMap<>();
        map.put("message", msg);
        map.put("code", "200");
        return ResponseEntity.ok(map);
    }
    public static ResponseEntity ok(String msg,Object data){
        Map<String, Object> map = new HashMap<>();
        map.put("message", msg);
        map.put("code", "200");
        map.put("data", data);
        return ResponseEntity.ok(map);
    }
    public static ResponseEntity error(String msg){
        Map<String, Object> map = new HashMap<>();
        map.put("message", msg);
        map.put("code", "500");
        return ResponseEntity.ok(map);
    }
}
